#include <iostream>
using namespace std;

int kind;
int mp[26];

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int left = 0, right = 0, ret = n;
    
    while(right < n)
    {
        if(mp[s[right] - 'a']++ == 0) kind++;
        while(kind == 26)
        {
            ret = min(ret, right - left + 1);
            if(mp[s[left] - 'a']-- == 1) kind--;
            left++;
        }
        right++;
    }
    
    cout << ret << endl;
    return 0;
}
